package com.fenda.gallery

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.navigation.NavController
import androidx.navigation.findNavController
import androidx.navigation.fragment.NavHostFragment
import androidx.navigation.ui.NavigationUI

class MainActivity : AppCompatActivity() {
    private lateinit var controller: NavController
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        controller = (supportFragmentManager.findFragmentById(R.id.fragmentContainerView) as NavHostFragment?)!!.navController
        NavigationUI.setupActionBarWithNavController(this,controller)
    }
    //顶部导航栏
    override fun onSupportNavigateUp(): Boolean {
        return super.onSupportNavigateUp() || controller.navigateUp()
    }
}